<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ExoSimpleJob: exo Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="index.html" title="exo Reference Manual">
<link rel="up" href="exo-jobs.html" title="Part IV. Framework for threaded/asynchronous jobs">
<link rel="prev" href="ExoJob.html" title="ExoJob">
<link rel="next" href="exo-extensions.html" title="Part V. Extensions to existing frameworks">
<meta name="generator" content="GTK-Doc V1.33.1 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts">
<a href="#" class="shortcut">Top</a><span id="nav_description">  <span class="dim">|</span> 
                  <a href="#ExoSimpleJob.description" class="shortcut">Description</a></span><span id="nav_hierarchy">  <span class="dim">|</span> 
                  <a href="#ExoSimpleJob.object-hierarchy" class="shortcut">Object Hierarchy</a></span>
</td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="exo-jobs.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="ExoJob.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="exo-extensions.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="refentry">
<a name="ExoSimpleJob"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="ExoSimpleJob.top_of_page"></a>ExoSimpleJob</span></h2>
<p>ExoSimpleJob — Simple interface to execute functions asynchronously</p>
</td>
<td class="gallery_image" valign="top" align="right"></td>
</tr></table></div>
<div class="refsect1">
<a name="ExoSimpleJob.functions"></a><h2>Functions</h2>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="functions_proto_type">
<col class="functions_proto_name">
</colgroup>
<tbody>
<tr>
<td class="function_type">
<span class="returnvalue">gboolean</span>
</td>
<td class="function_name">
<span class="c_punctuation">(</span><a class="link" href="ExoSimpleJob.html#ExoSimpleJobFunc" title="ExoSimpleJobFunc ()">*ExoSimpleJobFunc</a><span class="c_punctuation">)</span> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="ExoJob.html" title="ExoJob"><span class="returnvalue">ExoJob</span></a> *
</td>
<td class="function_name">
<a class="link" href="ExoSimpleJob.html#exo-simple-job-launch" title="exo_simple_job_launch ()">exo_simple_job_launch</a> <span class="c_punctuation">()</span>
</td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect1">
<a name="ExoSimpleJob.other"></a><h2>Types and Values</h2>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="other_proto_type">
<col class="other_proto_name">
</colgroup>
<tbody><tr>
<td class="datatype_keyword"> </td>
<td class="function_name"><a class="link" href="ExoSimpleJob.html#ExoSimpleJob-struct" title="ExoSimpleJob">ExoSimpleJob</a></td>
</tr></tbody>
</table></div>
</div>
<div class="refsect1">
<a name="ExoSimpleJob.object-hierarchy"></a><h2>Object Hierarchy</h2>
<pre class="screen">    GObject
    <span class="lineart">╰──</span> <a class="link" href="ExoJob.html" title="ExoJob">ExoJob</a>
        <span class="lineart">╰──</span> ExoSimpleJob
</pre>
</div>
<div class="refsect1">
<a name="ExoSimpleJob.includes"></a><h2>Includes</h2>
<pre class="synopsis">#include &lt;exo/exo.h&gt;
</pre>
</div>
<div class="refsect1">
<a name="ExoSimpleJob.description"></a><h2>Description</h2>
<a class="link" href="ExoSimpleJob.html" title="ExoSimpleJob">ExoSimpleJob</a> can be used to execute
<p>functions asynchronously in an <a class="link" href="ExoJob.html" title="ExoJob"><span class="type">ExoJob</span></a> wrapper object. It is easier to
use than the <span class="type">GThread</span> system and provides basic signals to follow the
progress of an operation.</p>
</div>
<div class="refsect1">
<a name="ExoSimpleJob.functions_details"></a><h2>Functions</h2>
<div class="refsect2">
<a name="ExoSimpleJobFunc"></a><h3>ExoSimpleJobFunc ()</h3>
<pre class="programlisting"><span class="returnvalue">gboolean</span>
<span class="c_punctuation">(</span>*ExoSimpleJobFunc<span class="c_punctuation">)</span> (<em class="parameter"><code><a class="link" href="ExoJob.html" title="ExoJob"><span class="type">ExoJob</span></a> *job</code></em>,
                     <em class="parameter"><code><span class="type">GValueArray</span> *param_values</code></em>,
                     <em class="parameter"><code><span class="type">GError</span> **error</code></em>);</pre>
<p>Used by the <a class="link" href="ExoSimpleJob.html" title="ExoSimpleJob"><span class="type">ExoSimpleJob</span></a> to process the <em class="parameter"><code>job</code></em>
. See <a class="link" href="ExoSimpleJob.html#exo-simple-job-launch" title="exo_simple_job_launch ()"><code class="function">exo_simple_job_launch()</code></a>
for further details.</p>
<div class="refsect3">
<a name="ExoSimpleJobFunc.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>job</p></td>
<td class="parameter_description"><p>an <a class="link" href="ExoJob.html" title="ExoJob"><span class="type">ExoJob</span></a>.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>param_values</p></td>
<td class="parameter_description"><p>a <span class="type">GValueArray</span> of the <span class="type">GValue</span>s passed to
<a class="link" href="ExoSimpleJob.html#exo-simple-job-launch" title="exo_simple_job_launch ()"><code class="function">exo_simple_job_launch()</code></a>.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>error</p></td>
<td class="parameter_description"><p>return location for errors.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="ExoSimpleJobFunc.returns"></a><h4>Returns</h4>
<p> <code class="literal">TRUE</code> on success, <code class="literal">FALSE</code> in case of an error.</p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="exo-simple-job-launch"></a><h3>exo_simple_job_launch ()</h3>
<pre class="programlisting"><a class="link" href="ExoJob.html" title="ExoJob"><span class="returnvalue">ExoJob</span></a> *
exo_simple_job_launch (<em class="parameter"><code><a class="link" href="ExoSimpleJob.html#ExoSimpleJobFunc" title="ExoSimpleJobFunc ()"><span class="type">ExoSimpleJobFunc</span></a> func</code></em>,
                       <em class="parameter"><code><span class="type">guint</span> n_param_values</code></em>,
                       <em class="parameter"><code>...</code></em>);</pre>
<p>Allocates a new <a class="link" href="ExoJob.html" title="ExoJob"><span class="type">ExoJob</span></a> which executes the specified <em class="parameter"><code>func</code></em>
 with
the specified parameters.</p>
<p>An example could be:</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="k">static</span><span class="w"> </span><span class="n">gboolean</span><span class="w"></span>
<span class="nf">list_directory</span><span class="w"> </span><span class="p">(</span><span class="n">ExoJob</span><span class="w">      </span><span class="o">*</span><span class="n">job</span><span class="p">,</span><span class="w"></span>
<span class="w">                </span><span class="n">GValueArray</span><span class="w"> </span><span class="o">*</span><span class="n">param_values</span><span class="p">,</span><span class="w"></span>
<span class="w">                </span><span class="n">GError</span><span class="w">     </span><span class="o">**</span><span class="n">error</span><span class="p">)</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="n">GFileEnumerator</span><span class="w"> </span><span class="o">*</span><span class="n">enumerator</span><span class="p">;</span><span class="w"></span>
<span class="w">  </span><span class="n">GFileInfo</span><span class="w">       </span><span class="o">*</span><span class="n">info</span><span class="p">;</span><span class="w"></span>
<span class="w">  </span><span class="n">GError</span><span class="w">          </span><span class="o">*</span><span class="n">err</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">NULL</span><span class="p">;</span><span class="w"></span>
<span class="w">  </span><span class="n">GFile</span><span class="w">           </span><span class="o">*</span><span class="n">directory</span><span class="p">;</span><span class="w"></span>

<span class="w">  </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">exo_job_set_error_if_cancelled</span><span class="w"> </span><span class="p">(</span><span class="n">EXO_JOB</span><span class="w"> </span><span class="p">(</span><span class="n">job</span><span class="p">),</span><span class="w"> </span><span class="n">error</span><span class="p">))</span><span class="w"></span>
<span class="w">    </span><span class="k">return</span><span class="w"> </span><span class="n">FALSE</span><span class="p">;</span><span class="w"></span>

<span class="w">  </span><span class="n">directory</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">g_value_get_object</span><span class="w"> </span><span class="p">(</span><span class="n">g_value_array_get_nth</span><span class="w"> </span><span class="p">(</span><span class="n">param_values</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">));</span><span class="w"></span>

<span class="w">  </span><span class="n">enumerator</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">g_file_enumerate_children</span><span class="w"> </span><span class="p">(</span><span class="n">directory</span><span class="p">,</span><span class="w"></span>
<span class="w">                                          </span><span class="s">&quot;standard::display-name&quot;</span><span class="p">,</span><span class="w"></span>
<span class="w">                                          </span><span class="n">G_FILE_QUERY_INFO_NONE</span><span class="p">,</span><span class="w"></span>
<span class="w">                                          </span><span class="n">exo_job_get_cancellable</span><span class="w"> </span><span class="p">(</span><span class="n">job</span><span class="p">),</span><span class="w"></span>
<span class="w">                                          </span><span class="o">&amp;</span><span class="n">err</span><span class="p">);</span><span class="w"></span>

<span class="w">  </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">err</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="nb">NULL</span><span class="p">)</span><span class="w"></span>
<span class="w">    </span><span class="p">{</span><span class="w"></span>
<span class="w">      </span><span class="n">g_propagate_error</span><span class="w"> </span><span class="p">(</span><span class="n">error</span><span class="p">,</span><span class="w"> </span><span class="n">err</span><span class="p">);</span><span class="w"></span>
<span class="w">      </span><span class="k">return</span><span class="w"> </span><span class="n">FALSE</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>

<span class="w">  </span><span class="k">while</span><span class="w"> </span><span class="p">(</span><span class="n">TRUE</span><span class="p">)</span><span class="w"></span>
<span class="w">    </span><span class="p">{</span><span class="w"></span>
<span class="w">      </span><span class="n">info</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">g_file_enumerator_next_file</span><span class="w"> </span><span class="p">(</span><span class="n">enumerator</span><span class="p">,</span><span class="w"></span>
<span class="w">                                          </span><span class="n">exo_job_get_cancellable</span><span class="w"> </span><span class="p">(</span><span class="n">job</span><span class="p">),</span><span class="w"></span>
<span class="w">                                          </span><span class="o">&amp;</span><span class="n">err</span><span class="p">);</span><span class="w"></span>

<span class="w">      </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">info</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="nb">NULL</span><span class="p">)</span><span class="w"></span>
<span class="w">        </span><span class="k">break</span><span class="p">;</span><span class="w"></span>

<span class="w">      </span><span class="n">exo_job_info_message</span><span class="w"> </span><span class="p">(</span><span class="n">job</span><span class="p">,</span><span class="w"> </span><span class="n">_</span><span class="p">(</span><span class="s">&quot;Child: %s&quot;</span><span class="p">),</span><span class="w"></span>
<span class="w">                            </span><span class="n">g_file_info_get_display_name</span><span class="w"> </span><span class="p">(</span><span class="n">info</span><span class="p">));</span><span class="w"></span>

<span class="w">      </span><span class="n">g_object_unref</span><span class="w"> </span><span class="p">(</span><span class="n">info</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>

<span class="w">  </span><span class="n">g_object_unref</span><span class="w"> </span><span class="p">(</span><span class="n">enumerator</span><span class="p">);</span><span class="w"></span>

<span class="w">  </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">err</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="nb">NULL</span><span class="p">)</span><span class="w"></span>
<span class="w">    </span><span class="p">{</span><span class="w"></span>
<span class="w">      </span><span class="n">g_propagate_error</span><span class="w"> </span><span class="p">(</span><span class="n">error</span><span class="p">,</span><span class="w"> </span><span class="n">err</span><span class="p">);</span><span class="w"></span>
<span class="w">      </span><span class="k">return</span><span class="w"> </span><span class="n">FALSE</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="w">  </span><span class="k">else</span><span class="w"></span>
<span class="w">    </span><span class="p">{</span><span class="w"></span>
<span class="w">      </span><span class="k">return</span><span class="w"> </span><span class="n">TRUE</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="p">...</span><span class="w"></span>

<span class="n">GFile</span><span class="w"> </span><span class="o">*</span><span class="n">file</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">g_file_new_for_path</span><span class="w"> </span><span class="p">(</span><span class="s">&quot;/home/user&quot;</span><span class="p">);</span><span class="w"></span>
<span class="n">ExoJob</span><span class="w"> </span><span class="o">*</span><span class="n">job</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">exo_simple_job_launch</span><span class="w"> </span><span class="p">(</span><span class="n">list_directory</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">G_TYPE_FILE</span><span class="p">,</span><span class="w"> </span><span class="n">file</span><span class="p">);</span><span class="w"></span>
<span class="n">g_signal_connect</span><span class="w"> </span><span class="p">(</span><span class="n">job</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;info-message&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">G_CALLBACK</span><span class="w"> </span><span class="p">(</span><span class="n">update_some_widget</span><span class="p">),</span><span class="w"> </span><span class="n">widget</span><span class="p">);</span><span class="w"></span>
<span class="n">g_signal_connect</span><span class="w"> </span><span class="p">(</span><span class="n">job</span><span class="p">,</span><span class="w"> </span><span class="s">&quot;finished&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">G_CALLBACK</span><span class="w"> </span><span class="p">(</span><span class="n">unref_the_job_object</span><span class="p">),</span><span class="w"> </span><span class="nb">NULL</span><span class="p">);</span><span class="w"></span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>The caller is responsible to release the returned <a class="link" href="ExoJob.html" title="ExoJob"><span class="type">ExoJob</span></a> object
using <code class="function">g_object_unref()</code> when no longer needed.</p>
<div class="refsect3">
<a name="exo-simple-job-launch.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>func</p></td>
<td class="parameter_description"><p>the <a class="link" href="ExoSimpleJob.html#ExoSimpleJobFunc" title="ExoSimpleJobFunc ()"><span class="type">ExoSimpleJobFunc</span></a> to execute the job.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>n_param_values</p></td>
<td class="parameter_description"><p>the number of parameters to pass to the <em class="parameter"><code>func</code></em>
.</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>...</p></td>
<td class="parameter_description"><p>a list of <span class="type">GType</span> and parameter pairs (exactly
<em class="parameter"><code>n_param_values</code></em>
pairs) that are passed to <em class="parameter"><code>func</code></em>
.</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="exo-simple-job-launch.returns"></a><h4>Returns</h4>
<p> the launched <a class="link" href="ExoJob.html" title="ExoJob"><span class="type">ExoJob</span></a>.</p>
</div>
</div>
</div>
<div class="refsect1">
<a name="ExoSimpleJob.other_details"></a><h2>Types and Values</h2>
<div class="refsect2">
<a name="ExoSimpleJob-struct"></a><h3>ExoSimpleJob</h3>
<pre class="programlisting">typedef struct _ExoSimpleJob ExoSimpleJob;</pre>
<p>The <a class="link" href="ExoSimpleJob.html" title="ExoSimpleJob"><span class="type">ExoSimpleJob</span></a> struct contains only private fields and should not be
directly accessed.</p>
</div>
</div>
<div class="refsect1">
<a name="ExoSimpleJob.see-also"></a><h2>See Also</h2>
<a class="link" href="ExoJob.html" title="ExoJob">ExoJob</a>
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.33.1</div>
</body>
</html>